<?php
// 本类由系统自动生成，仅供测试用途
class LoginAction extends Action {
    public function index(){
		$this->display();
    }
	/*登陆*/
    public function login()
	{
		session_start();
		//$this->checkLogin();
		//dump($_POST);
        $name = $_POST['username'];
        $password = $_POST['password'];

		if($name==null)
		{
			$this->assign('jumpUrl','__APP__');
			$this->assign('waitSecond',2);
			$this->error('用户名或密码错误，请重试！');
		}
		else
		{
			$user = M('user');
			$cond['username']=$name;
			$cond['password']=$password;
			$result = $user->where($cond)->select();
			//dump($result);
			if($result!=null)
			{
				$_SESSION['online']=$name;
				$_SESSION['power']=$result[0]['power'];
				if($_SESSION['power']=='1'){
					$this->assign('jumpUrl','__APP__/Service/xlgtzx');
				}else{
					$this->assign('jumpUrl','__APP__/Info/gaikuang');
				}

				$this->assign('waitSecond',2);
				$this->success('登陆成功！');
			}
			else
			{
				$this->assign('jumpUrl','__APP__');
				$this->assign('waitSecond',2);
				$this->error('用户名或密码错误，请重试！');
			}
		}
    }
}